package stu.info.student.info.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import stu.info.student.info.entity.Sloc;
import stu.info.student.info.mapper.slocMapper;

import java.util.List;

@Slf4j
@Api(tags ="楼栋管理模块")
@RestController
@RequestMapping("/sloc")
public class slocController {
    @Autowired
    private slocMapper slocMapper;

    @ApiOperation("添加楼栋")
    @PostMapping("/add")
    int addSloc(@RequestBody Sloc sloc)
    {
        slocMapper.insert(sloc);
        log.debug("添加楼栋成功>>>{}号",sloc);
        return 200;
    }

    @ApiOperation("删除楼栋")
    @PostMapping("/delete")
    int deleteSloc(Long snum)
    {
        slocMapper.deleteById(snum);
        return 200;
    }

    @ApiOperation("查询楼栋")
    @PostMapping("/select")
    List<Sloc> getSloc()
    {
        return slocMapper.select();
    }
}
